Skip to content

Conversation

@grzpiotrowski
Copy link
Contributor

This PR refactors the Gateway API DNS helper functions to improve maintainability and aid in further enhancing the tests, refactoring particularly around the
cluster-ingress-operator/test/e2e/util_gatewayapi_test.go: assertExpectedDNSRecords function.

This is a follow up to comments in PR #1213 which added Gateway API DNS e2e tests.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Apr 29, 2025
@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Apr 29, 2025

@grzpiotrowski: This pull request references NE-2032 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.19.0" version, but no target version was set.

In response to this:

This PR refactors the Gateway API DNS helper functions to improve maintainability and aid in further enhancing the tests, refactoring particularly around the
cluster-ingress-operator/test/e2e/util_gatewayapi_test.go: assertExpectedDNSRecords function.

This is a follow up to comments in PR #1213 which added Gateway API DNS e2e tests.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot requested review from alebedev87 and gcs278 April 29, 2025 14:30
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Apr 29, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign miheer for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@grzpiotrowski
Copy link
Contributor Author

"Error executing test process"

Unrelated, I think.

/retest

@candita
Copy link
Contributor

candita commented Apr 30, 2025

/assign
/assign @alebedev87

@candita
Copy link
Contributor

candita commented May 12, 2025

/refresh

Copy link
Contributor

@alebedev87 alebedev87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor remarks. There was a remark in the previous PR about the cleanup function. Do you think you can consider it too?

Comment on lines +713 to +715
if err != nil {
return false, err
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does checkDNSRecordExpectation even return an error? I can only see nils returned. If no error can be returned from checkDNSRecordExpectation then it has to return only 1 value (bool).

Copy link
Contributor

@candita candita May 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to see the messages that are logged here, be returned to the caller in this err variable so the caller can figure out what to do with the message, instead of logging it here. Some messages work great for polling, e.g. "DNSRecord %s found but not yet published, retrying...", but don't make sense if you wanted to reuse this function in the future for a one-time call instead of repeated polling.

So let the caller decide what to do with the values returned.

Copy link
Contributor

@alebedev87 alebedev87 May 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I overlooked this. Indeed, checkDNSRecordExpectation can be a simple function, not a test helper. The logging is better to be done upper the call stack along with the other logs on the same level.

Even a single error return value can be enough:

if err := checkDNSRecordExpectation(dnsRecords, exp, shouldBePresent); err != nil {
    t.Log(err)
    return false, nil
}

Comment on lines +707 to +708
if err := kclient.List(ctx, dnsRecords, client.InNamespace(operatorcontroller.DefaultOperandNamespace)); err != nil {
return false, fmt.Errorf("failed to list DNSRecords: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In most of the polling cases we log the error and retry the API operator. Returning an error would break the polling loop.

Suggested change
if err := kclient.List(ctx, dnsRecords, client.InNamespace(operatorcontroller.DefaultOperandNamespace)); err != nil {
return false, fmt.Errorf("failed to list DNSRecords: %v", err)
if err := kclient.List(ctx, dnsRecords, client.InNamespace(operatorcontroller.DefaultOperandNamespace)); err != nil {
t.Logf("Failed to list DNSRecords: %v", err)
return false, nil

return false, nil
}
for exp, shouldBePresent := range expectations {
expectationMet, err := checkDNSRecordExpectation(t, *dnsRecords, exp, shouldBePresent)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine to pass by pointer to gain some CPU cycles on copying of all DNSRecords of the cluster.

Suggested change
expectationMet, err := checkDNSRecordExpectation(t, *dnsRecords, exp, shouldBePresent)
expectationMet, err := checkDNSRecordExpectation(t, dnsRecords, exp, shouldBePresent)

Unfortunately, go doesn't have pointers to const (hi, C++!) to benefit from the pointer parameter and ensure no modification on the pointed object. But it's quite common to pass by pointer even in read-only cases.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree.

if haveExpectNotPresent {
t.Logf("Continuing polling to ensure non-expected DNSRecords do not exist...")
if !shouldBePresent {
t.Logf("DNSRecord %s found but expected it absent.", exp.dnsName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
t.Logf("DNSRecord %s found but expected it absent.", exp.dnsName)
t.Logf("DNSRecord %q found but expected to be absent; retrying...", exp.dnsName)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

t.Logf("DNSRecord %s found but not yet published, retrying...", exp.dnsName)
return false, nil
}
t.Logf("DNSRecord %s found & published as expected", exp.dnsName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
t.Logf("DNSRecord %s found & published as expected", exp.dnsName)
t.Logf("DNSRecord %q found and published as expected", exp.dnsName)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return false, nil
}
return nil
t.Logf("DNSRecord %s correctly absent", exp.dnsName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
t.Logf("DNSRecord %s correctly absent", exp.dnsName)
t.Logf("DNSRecord %q absent as expected", exp.dnsName)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

// isPublished returns true if the DNSRecord.Status.Zones contains a Published condition = True.
func isPublished(rec v1.DNSRecord) bool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be consistent in the naming with dnsRecordMatches:

Suggested change
func isPublished(rec v1.DNSRecord) bool {
func dnsRecordPublished(rec v1.DNSRecord) bool {

return !haveExpectNotPresent, nil
})
if !isPublished(rec) {
t.Logf("DNSRecord %s found but not yet published, retrying...", exp.dnsName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@candita candita left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks much better, thanks. Just a few nits.

t.Logf("DNSRecord %s found but not yet published, retrying...", exp.dnsName)
return false, nil
}
t.Logf("DNSRecord %s found & published as expected", exp.dnsName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if !expectationsMet {
return fmt.Errorf("failed to observe expected DNSRecords: %v", err)
if shouldBePresent {
t.Logf("DNSRecord %s not found, retrying...", exp.dnsName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return false, nil
}
return nil
t.Logf("DNSRecord %s correctly absent", exp.dnsName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@openshift-bot
Copy link
Contributor

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@openshift-ci openshift-ci bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Aug 19, 2025
@openshift-bot
Copy link
Contributor

Stale issues rot after 30d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle rotten
/remove-lifecycle stale

@openshift-ci openshift-ci bot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Sep 18, 2025
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 18, 2025
@openshift-merge-robot
Copy link
Contributor

PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@openshift-ci openshift-ci bot added the lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. label Sep 18, 2025
@candita
Copy link
Contributor

candita commented Sep 22, 2025

/remove-lifecycle rotten

@openshift-ci openshift-ci bot removed the lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. label Sep 22, 2025
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 3, 2025

@grzpiotrowski: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/okd-scos-e2e-aws-ovn db194fa link false /test okd-scos-e2e-aws-ovn
ci/prow/e2e-aws-ovn-single-node db194fa link false /test e2e-aws-ovn-single-node
ci/prow/e2e-aws-ovn-serial db194fa link true /test e2e-aws-ovn-serial
ci/prow/e2e-azure-operator db194fa link true /test e2e-azure-operator
ci/prow/hypershift-e2e-aks db194fa link true /test hypershift-e2e-aks
ci/prow/e2e-gcp-operator db194fa link true /test e2e-gcp-operator
ci/prow/e2e-aws-ovn-hypershift-conformance db194fa link true /test e2e-aws-ovn-hypershift-conformance
ci/prow/e2e-aws-ovn db194fa link true /test e2e-aws-ovn
ci/prow/e2e-aws-operator db194fa link true /test e2e-aws-operator
ci/prow/e2e-hypershift db194fa link true /test e2e-hypershift
ci/prow/e2e-aws-ovn-upgrade db194fa link true /test e2e-aws-ovn-upgrade
ci/prow/e2e-aws-ovn-serial-1of2 db194fa link true /test e2e-aws-ovn-serial-1of2
ci/prow/e2e-aws-ovn-serial-2of2 db194fa link true /test e2e-aws-ovn-serial-2of2

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants